import { GRankTabBar } from "./GRankTabBar";
import { GBoxDirection } from "../../../../com/mui/containers/globalVariable/GBoxDirection";
import { MuiEvent } from "../../../../com/mui/events/MuiEvent";
import { EventName } from "../../mvc/EventName";
import { GTextBar } from "./GTextBar";
import { GTextFormat } from "../../../common/GTextFormat";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
type int = number;
//class RankTabBar
    
    export  class RankTabBar /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._rankTabBarDp = [];
            this._textBarDpList = [];
            this._textEventTypeList = [];
            this.init();
            return;
        }

        public set rankTabBarDp(arg1: Array<any>)
        {
            this._rankTabBarDp = arg1;
            this._rankTabBar.dataProvider = this._rankTabBarDp;
            return;
        }

        public set textBarDpList(arg1: Array<any>)
        {
            this._textBarDpList = arg1;
            this._textBar.dataProvider = this._textBarDpList[0];
            return;
        }

        public set textEventTypeList(arg1: Array<any>)
        {
            this._textEventTypeList = arg1;
            return;
        }

        /* internal  */init(): void
        {
            this._rankTabBar = new GRankTabBar();
            this._rankTabBar.buttonWidth = 90;
            this._rankTabBar.buttonHeight = 23;
            this._rankTabBar.verticalGap = 2;
            this._rankTabBar.x = 3;
            this._rankTabBar.y = 0;
            this._rankTabBar.direction = GBoxDirection.VERTICAL;
            this._rankTabBar.dataProvider = this._rankTabBarDp;
            this._rankTabBar.selectedIndex = 0;
            this._rankTabBar.buttonStyleName = "PageButton";
            this._rankTabBar.addEventListener(MuiEvent.GTABBAR_SELECTED_CHANGE, this.onTabBarSelectedHandler);
            this._rankTabBar.addEventListener(EventName.RankBarInitEnd, this.onRankButtonInitEndHandler);
            addChild(this._rankTabBar);
            this._textBar = new GTextBar();
            this._textBar.width = 100;
            this._textBar.verticalGap = 0;
            this._textBar.x = 0;
            this._textBar.y = 0;
            this._textBar.direction = GBoxDirection.VERTICAL;
            this._textBar.dataProvider = this._textBarDpList[0];
            this._textBar.selectedIndex = 0;
            var loc1=new GTextFormat("", 12, 15859633);
            this._textBar.textformat = loc1;
            var loc2=new GTextFormat("", 12, 11661311, null, null, null, null, null, flash.text.TextFormatAlign.CENTER);
            this._textBar.normalTextformat = loc2;
            this._textBar.addEventListener(MuiEvent.GTABBAR_SELECTED_CHANGE, this.onTextBarSelectedHandler);
            this._textBar.addEventListener(EventName.RankBarInitEnd, this.onTextInitEndHandler);
            addChild(this._textBar);
            return;
        }

        /* internal  */onTabBarSelectedHandler(arg1: MuiEvent): void
        {
            this._buttonBarSelectedIndex = this._rankTabBar.selectedIndex;
            this._textBar.dataProvider = this._textBarDpList[this._buttonBarSelectedIndex];
            return;
        }

        /* internal  */onRankButtonInitEndHandler(arg1: Object /* flash.events.Event */): void
        {
            this._textBar.dataProvider = this._textBarDpList[this._oneIdx];
            this._buttonBarSelectedIndex = this._oneIdx;
            return;
        }

        /* internal  */onTextBarSelectedHandler(arg1: MuiEvent): void
        {
            if (this._isAssign) 
            {
                this._isAssign = false;
                this._textBar.selectedIndex = this._twoIdx;
            }
            var loc1=this._textBar.selectedIndex;
            var loc2=this._textEventTypeList[this._buttonBarSelectedIndex][loc1];
            Dispatcher.dispatchEvent(new DataEvent(EventName.RankingTypeChange, loc2));
            return;
        }

        /* internal  */onTextInitEndHandler(arg1: Object /* flash.events.Event */): void
        {
            this._rankTabBar.resetButtonPos(this._rankTabBar.selectedIndex, this._textBar.height);
            var loc1=this._rankTabBar.getFirstBlankPos();
            this._textBar.x = loc1.x;
            this._textBar.y = loc1.y;
            return;
        }

        public selectedAssignType(arg1: Object): void
        {
            this._isAssign = true;
            this._oneIdx = arg1.oneIdx as int;
            this._twoIdx = arg1.twoIdx as int;
            this._rankTabBar.selectedIndex = this._oneIdx;
            this._buttonBarSelectedIndex = this._oneIdx;
            this._textBar.dataProvider = this._textBarDpList[this._oneIdx];
            this._textBar.selectedIndex = this._twoIdx;
            var loc1=this._textEventTypeList[this._oneIdx][this._twoIdx];
            Dispatcher.dispatchEvent(new DataEvent(EventName.RankingTypeChange, loc1));
            return;
        }

        /* internal */ /* var */_rankTabBarDp: Array<any>;

        /* internal */ /* var */_textBarDpList: Array<any>;

        /* internal */ /* var */_textEventTypeList: Array<any>;

        /* internal */ /* var */_rankTabBar: GRankTabBar;

        /* internal */ /* var */_textBar: GTextBar;

        /* internal */ /* var */_buttonBarSelectedIndex: int;

        /* internal */ /* var */_oneIdx: int=0;

        /* internal */ /* var */_twoIdx: int=0;

        /* internal */ /* var */_isAssign: Boolean=false;
    }
